




using System;
using System.Data;using THSERP.BusinessEntities;using THSERP.BaseProvider;
using System.Collections.Generic;
using System.Reflection;
using System.Text;
using System.Windows.Forms;
using THSLib;using THSERP.BaseProvider;

namespace THSERP.Modules.Customer
{
    public class CustomerEntities : ERPModuleEntities
    {
        #region Declare Constant
        public readonly static String strARCustomersObjectName = "ARCustomers";

        public readonly static String strARCustomerContactsObjectName = "ARCustomerContacts";
        #endregion
        
        #region Declare all entities variables
        private ARCustomersInfo _aRCustomersObject;
        private ARCustomerContactsInfo _aRCustomerContactsObject;
 
        public THSList<ARCustomerContactsInfo> lstARCustomerContacts;

        #endregion

        #region Public Properties
        public ARCustomersInfo ARCustomersObject
        {
            get
            {
                return _aRCustomersObject;
            }
            set
            {
                _aRCustomersObject = value;
            }
        }
        public ARCustomerContactsInfo aRCustomerContactsObject
        {
            get
            {
                return _aRCustomerContactsObject;
            }
            set
            {
                _aRCustomerContactsObject = value;
            }
        }

        public THSList<ARCustomerContactsInfo> ARCustomerContactsList
        {
            get
            {
                return lstARCustomerContacts;
            }
            set
            {
                lstARCustomerContacts = value;
            }
        }
       
        #endregion

        #region Constructor
        public CustomerEntities()
            : base()
        {
            _aRCustomersObject = new ARCustomersInfo();

            _aRCustomerContactsObject = new ARCustomerContactsInfo();

            lstARCustomerContacts = new THSList<ARCustomerContactsInfo>();
        }

        #endregion

        #region Init Main Object,Module Objects functions
        public override void InitMainObject()
        {
            MainObject = ARCustomersObject;
        }

        public override void InitModuleObjects()
        {
            ModuleObjects.Add("ARCustomerContacts", aRCustomerContactsObject);
        }

        public override void InitModuleObjectList()
        {            
            lstARCustomerContacts = new THSList<ARCustomerContactsInfo>();
            //lstARCustomerContacts.InitTHSList(this, THSUtil.GetTableNameFromBusinessObjectType(typeof(ARCustomerContactsInfo)));
            lstARCustomerContacts.InitTHSList(this, "ARCustomers", "ARCustomerContacts");
        }

        public override void InitGridControlInTHSList()
        {
            lstARCustomerContacts.InitTHSListGridControl();
        }

        public override void SetDefaultModuleObjectsList()
        {
            try
            {
                lstARCustomerContacts.SetDefaultListAndRefreshGridControl();

            }
            catch (Exception)
            {
                return;
            }
        }

        #endregion

        #region Invalidate Module Objects functions
        public override void InvalidateMainObject(int iObjectID)
        {
            base.InvalidateMainObject(iObjectID);
        }

        public override void InvalidateModuleObjects(int iObjectID)
        {
            ARCustomerContactsList.Invalidate(iObjectID);
        }


        #endregion

        #region Save Module Objects functions

        public override void SaveModuleObjects()
        {
            ARCustomerContactsList.SaveItemObjects(true);
        }

        #endregion


    }
}
